package com.maple.phoneward.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import com.maple.phoneward.activity.LockPatternActivity;
import com.maple.phoneward.constants.Constants;
import com.maple.phoneward.utils.AppUtil;
import com.maple.phoneward.utils.Logger;

/**
 * LockedService.java
 * 
 * @author YaJian Qiu
 * @time 2013-3-30 上午9:55:25<br>
 *       本类描述：锁定服务
 * 
 */
public class LockedService extends Service {

	private static final String TAG = "LockedService";


	class MyBind extends Binder {

	}

	@Override
	public IBinder onBind(Intent intent) {
		return new MyBind();
	}

	@Override
	public void onCreate() {
		Logger.d(TAG, "锁定服务创建");
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Logger.d(TAG, "在锁定服务中执行命令");

		AppUtil.saveToSharedPreferences(this, Constants.IS_LOCK_MODEL, true);
		Intent it = new Intent(this, LockPatternActivity.class);
		it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(it);
		stopSelf();
		return super.onStartCommand(intent, flags, startId);
	}

	@Override
	public void onDestroy() {
		Logger.d(TAG, "锁定服务销毁");
	}

}
